Skip to content

Add versioned benchmark JSON schema validation (v1) - #10

Merged
DaBestCode merged 5 commits into
DaBestCode:mainfrom
faizan-7890:feat/benchmark-schema-v1
Sep 8, 2026
Merged

Add versioned benchmark JSON schema validation (v1)#10
DaBestCode merged 5 commits into
DaBestCode:mainfrom
faizan-7890:feat/benchmark-schema-v1

Conversation

@faizan-7890

Copy link
Copy Markdown
Contributor

Fixes #3

Summary

This PR introduces schema-based validation for benchmark result JSON files.

Changes

  • Added a Draft 2020-12 JSON schema:
    • schemas/benchmark-v1.schema.json
  • Added schema validation tests:
    • tests/test_benchmark_schema.py
    • validates the checked-in Qwen3 microbenchmark result file against schema v1
    • includes parameterized negative tests to ensure required fields are enforced
  • Documented schema/version compatibility expectations in benchmark results docs (if applicable in this branch)

Schema/versioning policy

  • Additive optional fields remain compatible within schema v1.
  • Removing or renaming fields requires a new schema version.
  • Semantic meaning changes to existing fields require a new schema version.

Validation run

  • ruff check .
  • ruff format --check .
  • mypy src
  • pytest -q

All checks pass locally.

Copilot AI lite review requested due to automatic review settings September 7, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The schema/tests do not currently enforce the required protocol field per Issue #3 acceptance criteria, so the validation guarantees are incomplete.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a versioned (v1) JSON Schema and pytest-based validation to make checked-in benchmark result JSON files machine-checkable and enforce required metadata fields.

Changes:

  • Introduces Draft 2020-12 JSON Schema for benchmark results (schema_version: 1).
  • Adds tests that validate the checked-in Qwen3 microbenchmark result file against the schema and exercise required-field failures.
File summaries
File Description
schemas/benchmark-v1.schema.json Adds the v1 JSON Schema definition for benchmark result files.
tests/test_benchmark_schema.py Adds pytest validation of the checked-in benchmark JSON against the schema plus negative required-field tests.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +7 to +23
"required": [
"schema_version",
"claim_scope",
"model",
"model_revision",
"device",
"runs",
"summary",
"kind",
"prompt_tokens",
"generated_tokens",
"warmup_tokens",
"trials",
"budget",
"buffer_size",
"seed"
],
Comment on lines +19 to +23
schema = load_json(SCHEMA_PATH)
data = load_json(QWEN_RESULT_PATH)
validator = Draft202012Validator(schema)
errors = sorted(validator.iter_errors(data), key=lambda e: list(e.path))
assert errors == [], [e.message for e in errors]
Comment thread tests/test_benchmark_schema.py Outdated
Comment on lines +26 to +42
REQUIRED_FIELDS = [
"schema_version",
"claim_scope",
"model",
"model_revision",
"device",
"runs",
"summary",
"kind",
"prompt_tokens",
"generated_tokens",
"warmup_tokens",
"trials",
"budget",
"buffer_size",
"seed",
]
@faizan-7890

Copy link
Copy Markdown
Contributor Author

Hi DaBestCode, could you please approve workflows for this PR? Thank you!

@faizan-7890

Copy link
Copy Markdown
Contributor Author

Addressed Copilot review feedback in latest commits:

  • Added required protocol field to schemas/benchmark-v1.schema.json
  • Added protocol to results/qwen3-0.6b-mps-microbenchmark.json
  • Added Draft202012Validator.check_schema(schema) in tests
  • Removed hardcoded required-fields list and now derive required keys from schema

Local checks pass:

  • ruff check .
  • ruff format --check .
  • mypy src
  • pytest -q

Could a maintainer please approve workflows so remaining CI can run? Thanks!

@faizan-7890

Copy link
Copy Markdown
Contributor Author

could a maintainer please approve workflows for this PR so CI can continue? Thank you!

@DaBestCode DaBestCode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking this on. The schema direction is useful, but this needs four focused fixes before merge:

  1. Please remove the newly added top-level protocol field from both the fixture and schema. The issue guidance explicitly defines the protocol through the existing required fields (kind, token counts, trials, budget, buffer, and seed) and asks not to change the producer format solely to add a key.
  2. Add jsonschema to the test extra in pyproject.toml. In a clean project environment, pytest -q currently fails during collection with ModuleNotFoundError: No module named 'jsonschema'.
  3. Add the schema compatibility policy to results/README.md: additive optional fields remain compatible within v1; removing/renaming fields or changing their semantic meaning requires a new schema version.
  4. Run ruff format on tests/test_benchmark_schema.py; ruff format --check . currently fails on the final assertion.

Verified locally: ruff check . and mypy src pass; formatting and pytest fail for the reasons above. Please rerun the complete CONTRIBUTING.md check list after updating.

@faizan-7890

Copy link
Copy Markdown
Contributor Author

hanks @DaBestCode! All four points have been addressed in commit 4fcae73:

│ 1. Removed the top-level protocol field from qwen3-0.6b-mps-microbenchmark.json and benchmark-v1.schema.json.
│ 2. Added jsonschema>=4.23 to the test extra in pyproject.toml.
│ 3. Added the schema compatibility policy to README.md.
│ 4. Formatted test_benchmark_schema.py with ruff format.

│ Reran the full CONTRIBUTING.md checklist locally (ruff check ., ruff format --check ., mypy src, pytest -q, and python -m build --no-
│ isolation); all checks pass.

@DaBestCode DaBestCode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all four prior findings. I reran the complete CONTRIBUTING.md suite locally; 34 tests and the package build pass.

There is one remaining schema-compatibility issue before approval:

  • RandKVConfig and both CLIs allow buffer_size=0, but the schema uses minimum: 1, so it rejects a valid benchmark result. Please change this to minimum: 0.
  • budget is an integer in RandKVConfig and argparse, but the schema declares it as number, which accepts fractional values the producer cannot emit. Please use type: integer with minimum: 1.

Please add a small regression test showing a zero buffer validates and a fractional budget does not. Everything else from the previous review is resolved.

@faizan-7890

Copy link
Copy Markdown
Contributor Author

Thanks @DaBestCode! Addressed in commit eda72c7:

│ 1. Changed buffer_size in benchmark-v1.schema.json to minimum: 0.
│ 2. Changed budget in benchmark-v1.schema.json to type: integer with minimum: 1.
│ 3. Added regression tests in test_benchmark_schema.py verifying zero buffer size validates and fractional budget
is
│ rejected.

│ The full CONTRIBUTING.md suite passed locally (36 tests passed and package build succeeded).

@DaBestCode DaBestCode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The latest commit resolves the remaining schema compatibility findings: zero-sized recency buffers validate, budgets are constrained to positive integers, and both cases have regression coverage. Verified locally with 36 tests plus Ruff, formatting, mypy, package build, and diff checks; the hosted Python 3.10/3.13 matrix and GitGuardian also pass.

@DaBestCode
DaBestCode merged commit 498ce9f into DaBestCode:main Sep 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Validate benchmark JSON with a versioned schema

3 participants